package com.xieyong.leetcode;

import java.util.Arrays;

public class Leetcode2410 {
    public static void main(String[] args) {
        Leetcode2410 leetcode2410 = new Leetcode2410();
        int[] players = {4,7,9};
        int[] trainers = {8,2,5,8};
        int i = leetcode2410.matchPlayersAndTrainers(players, trainers);
        System.out.println(i);

    }


    public int matchPlayersAndTrainers(int[] players, int[] trainers) {
        Arrays.sort(players);
        Arrays.sort(trainers);
        int n = players.length;
        int j = 0;
        for (int trainer : trainers) {
            if (j < n && players[j] <= trainer) {
                j++;
            }
        }
        return j;
    }
}
